package com.taotao.controller;

import com.taotao.pojo.EasyUITreeNode;
import com.taotao.pojo.TaotaoResult;
import com.taotao.service.ContentCategoryService;
import com.taotao.service.ItemCatService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * Created by new on 2018/6/9.
 */
@Controller
@RequestMapping("/content/category")
public class ContentCategoryController {

    @Autowired
    private ContentCategoryService contentCategoryService;

    @RequestMapping("/list")
    @ResponseBody
    private List<EasyUITreeNode> getCategoryList(@RequestParam(value = "id",defaultValue = "0") Long parentId){
        List<EasyUITreeNode> list = contentCategoryService.getCategoryList(parentId);
        return list;
    }

    @RequestMapping("/create")
    @ResponseBody
    private TaotaoResult createCategoryList(Long parentId, String name){
        TaotaoResult result = contentCategoryService.insertContentCategory(parentId,name);
        return result;
    }

    @RequestMapping("/delete")
    @ResponseBody
    private TaotaoResult deleteCategoryList(Long parentId, Long id){
        TaotaoResult result = contentCategoryService.deleteContentCategory(parentId,id);
        return result;
    }

    @RequestMapping("/update")
    @ResponseBody
    private TaotaoResult updateCategoryList(Long id, String name){
        TaotaoResult result = contentCategoryService.updateContenCategory(id,name);
        return result;
    }
}
